﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using System.Drawing;

using System.Drawing.Drawing2D;


namespace FXnaGis
{
    [Serializable]
    public class SimplePattern:PolyPattern
    {


        #region Private Variables

        private Color _fillColor;

        #endregion


        public SimplePattern()
        {
            Color c = StyleGlobal.RandomLightColor(1F);

            this.Configure(c);
 
        }





        private void Configure(Color fillColor)
        {
            
            _fillColor = fillColor;

        }


        /// <summary>
        /// Fills the path
        /// </summary>
        /// <param name="g">The Graphics device to draw to</param>
        /// <param name="gp">The GraphicsPath to fill using this pattern</param>
        public override void FillPath(Graphics g, GraphicsPath gp)
        {
            using (Brush b = new SolidBrush(_fillColor))
            {
                g.FillPath(b, gp);
            }
        }



        #region Properties

      
        public Color FillColor
        {
            get { return _fillColor; }
            set { _fillColor = value; }
        }

      
        public float Opacity
        {
            get { return _fillColor.A / 255F; }
            set
            {
                float val = value;
                if (val > 1) val = 1F;
                if (val < 0) val = 0F;
                _fillColor = Color.FromArgb((int)(val * 255), _fillColor.R, _fillColor.G, _fillColor.B);
            }
        }

        #endregion


    }
}
